package com.ruoyi.record.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.record.domain.WordHearRecord;
import com.ruoyi.record.mapper.WordHearRecordMapper;
import com.ruoyi.record.service.IWordHearRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 单词听力记录Service业务层处理
 *
 * @author ruoyi
 * 2025-07-02
 */
@Service
public class WordHearRecordServiceImpl implements IWordHearRecordService
{
    @Autowired
    private WordHearRecordMapper wordHearRecordMapper;


    @Autowired
    private WordRecordCommonService wordRecordCommonService;

    /**
     * 查询单词听力记录
     *
     * @param id 单词听力记录主键
     * @return 单词听力记录
     */
    @Override
    public WordHearRecord selectWordHearRecordById(Integer id)
    {
        return wordHearRecordMapper.selectWordHearRecordById(id);
    }

    /**
     * 查询单词听力记录列表
     *
     * @param wordHearRecord 单词听力记录
     * @return 单词听力记录
     */
    @Override
    public List<WordHearRecord> selectWordHearRecordList(WordHearRecord wordHearRecord)
    {
        return wordHearRecordMapper.selectWordHearRecordList(wordHearRecord);
    }

    @Override
    public List<WordHearRecord> selectSceneRecordList(WordHearRecord wordHearRecord)
    {
        return wordHearRecordMapper.selectSceneRecordList(wordHearRecord);
    }

    /**
     * 新增单词听力记录
     *
     * @param wordHearRecord 单词听力记录
     * @return 结果
     */
    @Override
    public int insertWordHearRecord(WordHearRecord wordHearRecord)
    {
        WordHearRecord record = wordRecordCommonService.insertList(wordHearRecord);
        record.setCreateTime(DateUtils.getNowDate());
        String date = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, record.getCreateTime());
        record.setDate(date);
        return wordHearRecordMapper.insertWordHearRecord(record);
    }

    /**
     * 修改单词听力记录
     *
     * @param wordHearRecord 单词听力记录
     * @return 结果
     */
    @Override
    public int updateWordHearRecord(WordHearRecord wordHearRecord)
    {
        wordHearRecord.setUpdateTime(DateUtils.getNowDate());
        return wordHearRecordMapper.updateWordHearRecord(wordHearRecord);
    }

    /**
     * 批量删除单词听力记录
     *
     * @param ids 需要删除的单词听力记录主键
     * @return 结果
     */
    @Override
    public int deleteWordHearRecordByIds(Integer[] ids)
    {
        return wordHearRecordMapper.deleteWordHearRecordByIds(ids);
    }

    /**
     * 删除单词听力记录信息
     *
     * @param id 单词听力记录主键
     * @return 结果
     */
    @Override
    public int deleteWordHearRecordById(Integer id)
    {
        return wordHearRecordMapper.deleteWordHearRecordById(id);
    }
}
